/**
 * Created by John on 2016/7/18.
 */
var mongo = new Mongo('localhost');
var db = mongo.getDB('capped');

db.createCollection('myCapped', {capped: true, size: 1048576, max: 5});

for (var i = 0; i < 10; i++) {
    db.getCollection('myCapped').insert({num: i});
}

var cursor = db.getCollection('myCapped').find();
cursor.forEach(function (item) {
    printjson(item);
});